#include "reminder.h"
#include <QVBoxLayout>
#include <QApplication>

Reminder::Reminder(QWidget *parent) :
    QWidget(parent)
{
    setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
    setGeometry(QApplication::desktop()->availableGeometry().width()-203,
                QApplication::desktop()->availableGeometry().height()-203,
                200,200);
    QVBoxLayout * main = new QVBoxLayout;
    QHBoxLayout *hlay = new QHBoxLayout;
    hlay->setAlignment(Qt::AlignLeft);

    QLabel *lb = new QLabel;
    lb->setPixmap(QPixmap(":/tray"));
    hlay->addWidget(lb);
    lb=new QLabel(tr("AWSD"));
    QFont font = lb->font();
    font.setBold(true);
    font.setPointSize(12);
    font.setFamily("Times");
    lb->setFont(font);
    hlay->addWidget(lb);
    main->addLayout(hlay);
    main->addStretch();

    hlay = new QHBoxLayout;
    hlay->setAlignment(Qt::AlignCenter);
    hlay->addWidget(&text);
    main->addLayout(hlay);
    main->addStretch();
    main->addStretch();
    setLayout(main);
    QPalette p = palette();
    p.setColor(QPalette::Window,QColor(51,51,255));
    setPalette(p);

    p=lb->palette();
    p.setColor(QPalette::WindowText,Qt::white);
    lb->setPalette(p);
    text.setPalette(p);
    font=text.font();
    font.setPointSize(12);
    font.setFamily("Times");
    text.setFont(font);

    connect(this,SIGNAL(mouseClick()),this,SLOT(close()));
}

void Reminder::mousePressEvent (QMouseEvent * event)
{
    emit mouseClick();
}

void Reminder::setMessage(const QString &message)
{
    text.setText(message);
    show();
}
